// #include <iostream>
// #include <unistd.h>
// #include "threadpool.hpp"
// using namespace std;
// string opers = "+-*/%$";

// int main()
// {
//     srand(time(0));
//     //1.创建线程池
//     ThreadPool<Task> tp;
//     tp.Start();
//     sleep(2);
//     //2.将任务交给线程池
//     while(1)
//     {
//         int data1 = rand()%10; 
//         int data2 = rand()%10; 
//         char oper = opers[rand() % opers.size()];
//         Task t(data1,data2,oper);

//         tp.Push(t);
//         cout << "main thread push a task: " << t.GetTaskLog() << endl;
//         sleep(1);
//     }
    
//     return 0;
// }


/************************单例模式******************************/
#include <iostream>
#include <unistd.h>
#include "singleton.hpp"
using namespace std;
string opers = "+-*/%$";

int main()
{
    srand(time(0));
    //1.创建线程池
    ThreadPool<Task>* tp = ThreadPool<Task>::GetInstance();
    tp->Start();
    sleep(2);
    //2.将任务交给线程池
    while(1)
    {
        int data1 = rand()%10; 
        int data2 = rand()%10; 
        char oper = opers[rand() % opers.size()];
        Task t(data1,data2,oper);

        tp->Push(t);
        cout << "main thread push a task: " << t.GetTaskLog() << endl;
        sleep(1);
    }
    
    return 0;
}